package net.wang.concurrency.test.publish;

import lombok.extern.slf4j.Slf4j;
import net.wang.concurrency.annoations.NotThreadSafe;
import org.junit.Test;

import java.util.Arrays;

@Slf4j
@NotThreadSafe
public class UnsafePublish {

    private String[] states = {"a", "b", "c"};

    public String[] getStates() {
        return states;
    }

    @Test
    public void unSafeTest() {
        UnsafePublish publish = new UnsafePublish();
        log.info("states = {}", Arrays.toString(publish.getStates()));
        publish.getStates()[0] = "d";
        log.info("states = {}", Arrays.toString(publish.getStates()));
    }
}
